<?php
class Form_Donate extends App_Dojo_Form
{    	
	public $_selectStates = array();
    
    public $_selectCountries = array();
	
	public $_noDecorators = array(
                                    'DijitElement',
	);
	
	public function init()
    {
        $this->setName('formDonate');
        
        $this->setMethod('post');
        
       	$this->setDecorators(array(    
			'FormElements',    
			array(
				'HtmlTag', 
				array(
					'tag' => 'dl',
					'class' => 'form normal'
					)
			),    
			'DijitForm',
		));
		
        $this->addElement(
        	'ValidationTextBox', 
        	'organization', 
        	array(
	            'label'          	=> 'Organization',
	            'required'       	=> true,
        		'promptMessage'		=> 'Enter organization name.',
	            'invalidMessage' 	=> 'Please type organization name.',
        		'maxlength'      	=> 100,
        		'trim'      		=> true,
	            'validators' 		=> array(
					'NotEmpty', 
        			array('StringLength', true, array(2, 100))
            	),
        	)
        );
        
        $this->addElement(
        	'ValidationTextBox', 
        	'address', 
        	array(
	            'label'          	=> 'Address',
	            'required'       	=> true,
        		'promptMessage'		=> 'Enter address.',
	            'invalidMessage' 	=> 'Please type the Address.',
        		'maxlength'      	=> 100,
        		'trim'      		=> true,
	            'validators' 		=> array(
					'NotEmpty', 
        			array('StringLength', true, array(2, 100))
            	),
        	)
        );
        
        $this->addElement(
        	'ValidationTextBox', 
        	'city', 
        	array(
	            'label'          	=> 'City',
	            'required'       	=> true,
        		'promptMessage'		=> 'Enter city name.',
	            'invalidMessage' 	=> 'Please type city name.',
        		'maxlength'      	=> 100,
        		'trim'      		=> true,
	            'validators' 		=> array(
					'NotEmpty', 
        			array('StringLength', true, array(2, 100))
            	),
        	)
        );
        
        $states = new States();        
        $this->_selectStates = $states->getDataDropDown();
        $this->addElement(
            'FilteringSelect',
            'id_state',
            array(
                'label' 			=> 'State',
            	'autocomplete'		=> true,
                'multiOptions' 		=> $this->_selectStates,            	
            )
        );
        
        $this->addElement(
        	'ValidationTextBox', 
        	'zip', 
        	array(
	            'label'          	=> 'Zip Code',
	            'required'       	=> true,
        		'regExp' 			=> '\d{5}([\-]\d{4})?$', 
        		'promptMessage'		=> 'Enter zip code.',
	            'invalidMessage' 	=> 'Invalid zip code (NNNNN) or (NNNNN-NNNN).',
        		'maxlength'      	=> 10,
        		'trim'      		=> true,
	            'validators' 		=> array(
					'NotEmpty', 
        			array('StringLength', true, array(5, 10))
            	),
        	)
        );
        
        $countries =  new Countries();
        $this->_selectCountries = $countries->getDataDropDown();
        $this->addElement(
            'FilteringSelect',
            'id_country',
            array(
                'label' 			=> 'Country',
            	'value' 			=> 'US',
            	'autocomplete'		=> true,
                'multiOptions' 		=> $this->_selectCountries,            	
            )
        );
        
        $this->addElement(
        	'CurrencyTextBox', 
        	'amount', 
        	array(
	            'label'          	=> 'Donation Amount',
	            'required'       	=> true,
        		'promptMessage'		=> 'Enter Donation Amount (in USD).',
	            'invalidMessage' 	=> 'Invalid amount.  Cents are required.',        		
        		'currency'			=> 'USD'            
        	)
        );
        
        $this->addElement(
        	'Button', 
        	'submitButton',
            array(
                'type'   	 => 'submit',
            	'required'   => false,
                'ignore'     => true,
                'label'      => 'Donate',
            	'iconClass'  => 'myIcons okIcon',
                'style' 		=> 'margin-top: 10px;',  
            )
        );
	}
}